package com.ListViewApp;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.Toast;  
public class ListViewActivity extends ListActivity 
{
	private TextView text;
	String[] listItems={"alpha", "beta", "gamma", "delta", "epsilon"}; 
	boolean[] listImages={true, false, true, false, true};
	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
		text = (TextView) findViewById(R.id.mainText);		
        setListAdapter(new ImageAdapter(this, R.layout.row, R.id.text1, R.id.image1, listItems, listImages ));
    }
	
	// when an item of the list is clicked
	@Override
	protected void onListItemClick(ListView list, View view, int position, long id) {
		super.onListItemClick(list, view, position, id);
   
		String selectedItem = (String) getListView().getItemAtPosition(position);
		//String selectedItem = (String) getListAdapter().getItem(position);
		
		text.setText("You clicked " + selectedItem + " at position " + position); 
 Toast.makeText(getApplicationContext(), selectedItem,
                         Toast.LENGTH_SHORT).show();		
	}	
}